package org.bai.meetingfilm.common.vo;

import org.bai.meetingfilm.exception.CommonServiceException;

public class BaseResponseVO<M> {

    private Integer code;

    private String message;

    private M data;

    public BaseResponseVO() {
    }

    public static BaseResponseVO<Object> success() {
        BaseResponseVO<Object> responseVO = new BaseResponseVO<>();
        responseVO.setCode(200);
        responseVO.setMessage("");
        return responseVO;
    }

    public static<M> BaseResponseVO<M> success(M data) {
        BaseResponseVO<M> responseVO = new BaseResponseVO<>();
        responseVO.setCode(200);
        responseVO.setMessage("");
        responseVO.setData(data);
        return responseVO;
    }

    public static<M> BaseResponseVO<M> serviceException(CommonServiceException exception) {
        BaseResponseVO<M> responseVO = new BaseResponseVO<>();
        responseVO.setCode(exception.getCode());
        responseVO.setMessage(exception.getMessage());
        return responseVO;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public M getData() {
        return data;
    }

    public void setData(M data) {
        this.data = data;
    }
}
